package com.xci.sys.api;

import com.xci.core.annotation.Authorize;
import com.xci.core.base.ApiController;
import com.xci.core.base.PageList;
import com.xci.core.base.RestMessage;
import com.xci.core.domain.PageModel;
import com.xci.core.internal.Const;
import com.xci.sys.entity.SysErrorLog;
import com.xci.sys.filter.ErrorLogFilter;
import com.xci.sys.service.ErrorLogService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 错误日志接口
 * @author 吕艳阳
 */
@ApiSort(10)
@Api(tags = "错误日志接口")
@Authorize
@RestController
@RequestMapping(value = "/api/sys/errorLog", produces = Const.P_JSON)
public class ErrorLogApiController extends ApiController {
    @Resource
    private ErrorLogService errorLogService;//错误日志服务

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "查询单个错误日志")
    @ApiImplicitParam(name = "id", value = "错误日志主键", required = true)
    @PostMapping("/selectById/{id}")
    public RestMessage<SysErrorLog> selectById(@PathVariable String id) {
        return RestMessage.success(errorLogService.selectById(id));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "查询错误日志分页列表")
    @PostMapping("/selectPageList")
    public RestMessage<PageList<SysErrorLog>> selectPageList(ErrorLogFilter filter, PageModel p) {
        return RestMessage.success(PageList.of(errorLogService.selectPageList(filter)));
    }
}